/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package contest.dao;

import contest.util.StringUtil;
import java.io.UnsupportedEncodingException;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Admin
 */
public class StatementFormat {

    public void setStringUTF8(int index, String value, PreparedStatement prepare) throws SQLException, UnsupportedEncodingException {
        prepare.setNString(index, StringUtil.convertToUTF8(
                StringUtil.trim(value)));
    }

    public void setString(int index, String value, PreparedStatement prepare) throws SQLException {
        prepare.setString(index, StringUtil.trim(value));
    }

    public void setInt(int index, int value, PreparedStatement prepare) throws SQLException {
        prepare.setInt(index, value);
    }

    public void setStringUTF8(int index, String value, CallableStatement cal) throws SQLException, UnsupportedEncodingException {
        cal.setNString(index, StringUtil.convertToUTF8(
                StringUtil.trim(value)));
    }

    public void setString(int index, String value, CallableStatement cal) throws SQLException {
        cal.setString(index, StringUtil.trim(value));
    }

    public void setInt(int index, int value, CallableStatement cal) throws SQLException {
        cal.setInt(index, value);
    }

    public void setObject(int index, Object value, PreparedStatement prepare) throws SQLException {
        prepare.setObject(index, value);
    }
}
